package com.lhy.controller;

import com.github.pagehelper.PageInfo;
import com.lhy.entity.Emp;
import com.lhy.service.EmpService;
import com.lhy.vo.EchartsVo;
import com.lhy.vo.EmpVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：罗昊宇
 * @Package：com.lhy.controller
 * @Project：springboot03
 * @name：EmpController
 * @Date：2024/3/11 0011  18:43
 * @Filename：EmpController
 */
@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    private EmpService empService;

    @RequestMapping("/getAll/{current}/{pageSize}")
    public PageInfo<Emp> getAll(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody EmpVo empVo) {
        System.out.println(empVo);
        PageInfo<Emp> empPageInfo = empService.getAll(current, pageSize, empVo);
        return empPageInfo;
    }

    @RequestMapping("/deleteEmp/{id}")
    public Integer deleteEmp(@PathVariable Integer id) {

        return empService.deleteEmp(id);
    }

    @RequestMapping("/insertEmp")
    public int insertEmp(@RequestBody Emp emp) {
        System.out.println(emp.toString());

        return empService.insertEmp(emp);
    }

    @RequestMapping("/updateEmp")
    public Integer updateEmp(@RequestBody Emp emp) {
        System.out.println(emp.toString());
        return empService.updateEmp(emp);

    }
    @RequestMapping("/pieChart")
    public List<EchartsVo> demo(EchartsVo echartsVo){

        List<EchartsVo> byCount = empService.getByCount(echartsVo);

        return byCount;

    }
    @RequestMapping("/echartsTree")
    public List<EchartsVo> echartsTree(EchartsVo echartsVo){

        return empService.getByCount2(echartsVo);

    }


}
